﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ObjectPool : MonoBehaviour
{
    public GameObject shellObj; //炮弹物体
    public static GameObject[] objArray;
    int poolNub;
    // Start is called before the first frame update
    private void Awake()
    {
        shellObj = Resources.Load("bullet") as GameObject;
        objArray = new GameObject[poolNub];
        if(shellObj!=null)
        {
            for (int i = 0; i < poolNub; i++)
            {
                var obj=Instantiate(shellObj, transform.position, Quaternion.identity);
                obj.transform.parent = transform;

                //关闭刚体开关
                obj.GetComponent<Rigidbody>().isKinematic = true;

                objArray[i] = obj;
            }
        }
    }
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
